package org.example.curriculum_design_6_16.enums;

/**
 * 社会服务等级评定枚举
 */
public enum SocialServiceGrade {
    
    EXCELLENT("优秀", 18.0, 20.0),
    GOOD("良好", 15.0, 17.9),
    PASS("合格", 12.0, 14.9),
    FAIL("不合格", 0.0, 11.9);
    
    private final String description;
    private final double minScore;
    private final double maxScore;
    
    SocialServiceGrade(String description, double minScore, double maxScore) {
        this.description = description;
        this.minScore = minScore;
        this.maxScore = maxScore;
    }
    
    public String getDescription() {
        return description;
    }
    
    public double getMinScore() {
        return minScore;
    }
    
    public double getMaxScore() {
        return maxScore;
    }
    
    /**
     * 根据分数获取等级
     * @param score 分数
     * @return 等级
     */
    public static SocialServiceGrade getGradeByScore(double score) {
        for (SocialServiceGrade grade : values()) {
            if (score >= grade.minScore && score <= grade.maxScore) {
                return grade;
            }
        }
        return FAIL;
    }
    
    /**
     * 获取等级描述
     * @param score 分数
     * @return 等级描述
     */
    public static String getGradeDescription(double score) {
        return getGradeByScore(score).getDescription();
    }
} 